function f=kfunc(x,type)

[dim1, dim2] = size(x);
switch lower(type)
   case {'epanechnikov','epan','epanech','e','quadratic','quad'}
      f= (3/4) * (1-x.^2) .* (abs(x)<=1);
   case {'biweight','quartic','bi','quart'}
      f = 15/16 * ((ones(dim1,dim2) - x.^2).^2)  .* (abs(x)<=1);
   case {'gauss','normal'}
      f = (1/sqrt(2*pi))*exp(-0.5*x.^2);    
   otherwise
      error('Kernel type not recognized');
end
	%
